package LeetCode;

import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName DataStructure
 * @Description: TODO
 * @date ${DAT}15:55
 */
public class interview50 {

    public static void main(String[] args) {
        String s = "leetcode";
        System.out.println(new interview50().firstUniqChar(s));
    }

    public char firstUniqChar(String s) {
        if (s.equals("")){
            return ' ';
        }
        char result = ' ';
        char[] arr = s.toCharArray();
        HashMap<Character,Integer> map = new HashMap<>();
        for (char c : arr) {
            map.put(c,0);
        }
        for (char c : arr) {
            map.put(c,map.get(c)+1);
        }
        for (char c :arr){
            if (map.get(c)==1){
                result = c;
                break;
            }
        }
        return result;
    }


}
